class Solution {
public:
    int lengthOfLongestSubstring(string s)
    {
        char hash[128];
        int maxl = 0;
        int left = 0, right = 0;
        while (right < s.size())
        {
            hash[s[right]]++;
            while (hash[s[right]] > 1)
            {
                hash[s[left]]--;
                left++;
            }
            maxl = max(maxl, right - left + 1);
            right++;
        }
        return maxl;
    }
};